/**
 * @author LKQ
 * @date 2022/1/30 15:00
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] nums = {1,1,1,1,1,1,1,1,1,1};
        solution.getMinDistance(nums, 1, 0);
    }
    public int getMinDistance(int[] nums, int target, int start) {
        int result = Integer.MAX_VALUE;
        for (int i =0; i < nums.length; i++) {
            if (nums[i] == target) {
                result = Math.min(result, Math.abs(i - start));
            }
        }
        return result;
    }
}
